package edu.uc.ui;

import com.foodview1.R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
 
/**
 * Main activity that extends the interface functionality of the camera.
 * @author Jimmy
 *
 */
public class CameraActivity extends Activity {
 
    private static final int CAMERA_PIC_REQUEST = 2500;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.camera);
 
        Button b = (Button)findViewById(R.id.Button01);
        b.setOnClickListener(new OnClickListener() {
			/**
			 * onClick method
			 */
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
			}
		});
    }
    
    /**
     * method onActivityResult - method for camera activity
     * 
     * @param requestCode
     * @param resultCode
     * @param data
     * 
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == CAMERA_PIC_REQUEST) {
              Bitmap image = (Bitmap) data.getExtras().get("data");
              ImageView imageview = (ImageView) findViewById(R.id.ImageView01);
              imageview.setImageBitmap(image);
        }
    }
}

	
//	@Override
//	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//	    if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
//	        if (resultCode == RESULT_OK) {
//	            // Image captured and saved to fileUri specified in the Intent
//	            Toast.makeText(this, "Image saved to:\n" +
//	                     data.getData(), Toast.LENGTH_LONG).show();
//	        } else if (resultCode == RESULT_CANCELED) {
//	            // User cancelled the image capture
//	        } else {
//	            // Image capture failed, advise user
//	        }
//	    }
//	}
//}
